package oop2.Task;

public class Company {
    String name;
    String address;
    String phoneNum;
    String service;
    String[] staff = new String[50];
    int index = 0;

    public void showCompany() {
        System.out.println("公司的名字:" + name + ",业务是:" + service);
        System.out.println("注册地址:" + address + ",联系电话:" + phoneNum + "\n");
        ;
    }

    public void addStaff(String staffName) {
//        System.out.println("新增员工");
        for (int i = 0; i < staff.length; i++) {
            if (staff[i] == null) {
                staff[i] = staffName;
                index = i;
                return;
            }
        }
    }

    public void showStaff() {
        System.out.println(name + "公司员工名单为:");
        for (int i = 0; i <= index; i++)
            System.out.print(staff[i] + " ");
        System.out.println();
    }

    //辞退员工
    public void dismiss(String staffName) {
        int a = 0;
        for (int i = 0; i <= index; i++) {
            if (staff[i].equals(staffName))
                a = i;
        }
        for (int i = a; i < index; i++) {
            staff[i] = staff[i + 1];
        }
        staff[index] = null;
        index--;
    }
}
